﻿@using BootstrapBlazor.Components
@using SqlSugar
@inherits WidgetComponentBase
@inject ISqlSugarClient db
@*<form>*@
@*<div class="form-group">*@
@if (Component is not null)
{
    <BootstrapInput Id="@(Component.Id)"
                    PlaceHolder="@(Component.Props["PlaceHolder"].StringValue)"
                    IsSelectAllTextOnFocus="@(Component.Props["IsSelectAllTextOnFocus"].BoolVal)"
                    DisplayText="@(Component.MutLanguage.GetLanguage())"
                    ShowLabel="@(Component.ShowLabel)"
                    IsDisabled="@Component.IsDisabled"
                    Color="@(Component.Color)"
                    OnEnterAsync="OnEnterAsync"
                    OnValueChanged="OnValueChanged"
    @bind-Value="@(Component.ValueInfo.StringValue)"></BootstrapInput>
}

@*</div>*@
@*</form>*@
@code {

    /// <summary>
    /// 回车后执行,执行这个控件带的参数
    /// </summary>
    /// <param name="value"></param>
    /// <returns></returns>
    public async Task OnEnterAsync(string value)
    {
        if (Component.Props["IsExecuteForEnter"].BoolVal)
        {
            List<SugarParameter> ps = new List<SugarParameter>();
            SugarParameter Msg = new SugarParameter("Msg", null, true);
            ps.Add(Msg);
            foreach (var item in Component.Props["Parameters"].MutilProperties)
            {
               // var container = FormDesigner.ContainerData.FindAllContainer(x=>x.Id==item.ContainerName).FirstOrDefault();
                foreach (var item2 in item.StringListValue)
                {
                }
            }
            var tabw = db.Ado.UseStoredProcedure().GetDataTable(Component.Props["StoreName"].StringValue, ps);
            if (Msg.Value != null)
            {
                await ToastService.Success("执行成功", $"返回:{Msg.Value}", autoHide: true);
            }
            else
            {
                await ToastService.Error("执行失败", "返回值为 null", autoHide: true);
            }
        }
        var ss = Component;
        await Task.Delay(100);
        ;

    }
    public async Task OnValueChanged(string value)
    {
        await Task.Delay(100);
        ;

    }
}
